export type DatabaseType = 'MYSQL' | 'ORACLE' | 'POSTGRESQL' | 'SQLSERVER' | string
export type ConnectType = 'SERVICE_NAME' | 'SID' | string

export interface CatalogSaveVo {
  catalogName: string
  host: string
  port: number
  databaseType: DatabaseType
  route: string
  userName: string
  password: string
  connectType: ConnectType
  dorisCatalogName: string
  defaultSystemCode: string
}

export interface CatalogVo {
  catalogName: string
  host: string
  port: number
  databaseType: DatabaseType
  route: string
  userName: string
  connectType: ConnectType
  databaseVersion?: string
  dorisCatalogName: string
  defaultSystemCode: string
  enabled?: boolean
  serverConnected?: boolean
  serverConnectedDt?: string
  jdbcConnected?: boolean
  jdbcConnectedDt?: string
  dorisConnected?: boolean
  dorisConnectedDt?: string
}

export interface Database {
  name: string
  enabled?: boolean
  systemCode?: string
  version?: string
}

export interface Table {
  name: string
  enabled?: boolean
  systemCode?: string
}

export interface Column {
  name: string
  type: string
  nullable?: boolean
  comment?: string
}

export interface Dimension {
  name: string
  type?: string
}

export type NodeType = 'SERVER' | 'CATALOG' | 'DATABASE' | 'TABLE'

export interface DataSourceTreeNode {
  id: string
  name: string
  // 后端可能返回 nodeType 或 type，两者兼容
  nodeType?: NodeType
  type?: NodeType
  enabled?: boolean
  databaseType?: DatabaseType
  activeDimensionName?: string | null
  children?: DataSourceTreeNode[]
  // 选择数据库或表节点时，前端填充的路径信息（便于右侧视图调用接口）
  catalogName?: string
  databaseName?: string
  tableName?: string
}